// index.js
Page({
  data: {
    newsList: []
  },
  onLoad: function() {
    this.getNewsByTag(1);
  },
  getNewsByTag: function(tag) {
    const url = `http://39.104.24.231:8082/news/tag/${tag}`;
    wx.request({
      url: url,
      method: 'GET',
      success: (res) => {
        if (res.data.status === 200) {
          this.setData({
            newsList: res.data.data
          });
        } else {
          wx.showToast({
            title: '请求失败：' + res.data.message,
            icon: 'none'
          });
        }
      },
      fail: (err) => {
        wx.showToast({
          title: '网络请求失败',
          icon: 'none'
        });
      }
    });
  }
});